<include file="/public/header" />

<style>
    .layui-card-body {
        padding-left: 0;
    }

    .layui-form-item .layui-input-inline {
        width: 220px;
    }
</style>

<div class="layui-fluid layui-bg-white">
    <form class="layui-form layui-form-fixed">
        <gt name="$data.id" value="0"><input type="text" name="id" value="{$data.id}" hidden=""></gt>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('产品名称')}</label>
            <div class="layui-input-block">
                <input name="title" value="{$data.title}" placeholder="{:__('请输入产品名称')}" type="text" class="layui-input"
                    lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('编码')}</label>
            <div class="layui-input-block">
                <input name="codes" value="{$data.codes}" placeholder="{:__('请输入编码')}" type="text" class="layui-input"
                    lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('库存预警数')}</label>
            <div class="layui-input-block">
                <input name="warnings" value="{$data.warnings}" placeholder="{:__('库存预警数')}" type="number" class="layui-input"
                    lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('规格')}</label>
            <div class="layui-input-block">
                <input name="spec" value="{$data.spec}" placeholder="{:__('请输入规格')}" type="text" class="layui-input"
                    lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('产品类型')}</label>
            <div class="layui-input-block">
                <select name="types">
                    <option value="0">{:__('选择产品类型')}</option>
                    <foreach $seriestype as $v>
                        <option value="{$v.id}" <if $data.types==$v.id>selected</if>>{$v.title}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('产品价')}</label>
            <div class="layui-input-block">
                <input name="price" value="{$data.price}" placeholder="{:__('请输入产品价')}" type="number"
                    class="layui-input" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('备注')}</label>
            <div class="layui-input-block">
                <input name="remark" value="{$data.remark}" placeholder="{:__('备注')}" type="text" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('搭配配方')}</label>
            <div class="layui-input-block">
                <div class="peifang" name="peifang"></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">产品图片</label>
            <div class="layui-input-block">
                <div class="layui-imagesbox">
                    <notempty name="$data['album']">
                        <volist name="$data['album']" id="vo">
                            <div class="layui-input-inline layui-uplpad-image">
                                <img src="{$vo.src}" lay-image-hover>
                                <input type="text" name="album[{$key}][src]" hidden value="{$vo.src}">
                                <input type="text" name="album[{$key}][title]" class="layui-input" value="{$vo.title}"
                                    placeholder="图片简介">
                                <span class="layui-badge layui-badge-red"
                                    onclick="layui.$(this).parent().remove();">删除</span>
                            </div>
                        </volist>
                    </notempty>
                    <div class="layui-input-inline layui-uplpad-image">
                        <div class="layui-upload-drag" lay-upload="album" data-type="multiple" data-accept="images"
                            data-size="102400">
                            <i class="layui-icon layui-icon-upload"></i>
                            <p>点击上传，或将文件拖拽到此处</p>
                            <div class="layui-hide"></div>
                        </div>
                        <input class="layui-upload-file" type="file" accept="" name="file">
                        <!-- <button type="button" class="layui-btn layui-btn-xs layui-btn-fluid" lay-choose="album"
                            data-type="multiple">
                            <i class="layui-icon layui-icon-windows"></i> 选择
                        </button> -->
                    </div>
                </div>
            </div>
        </div>
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">{:__('图文描述')}</label>
            <div class="layui-input-block">
                <textarea lay-editor id="detail" name="detail" type="layui-textarea">{$data.detail}</textarea>
            </div>
        </div> -->
        <div class="layui-footer layui-form-item layui-center ">
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
            <button class="layui-btn layui-btn-normal" lay-filter="submitIframe" type="button" lay-submit>提交</button>
        </div>
    </form>
</div>
<include file="/public/footer" />
<include file="/public/static" />
<script>
    layui.use(['form', 'jquery', 'layedit', 'admin'], function () {
        var form = layui.form;
        var jquery = layui.jquery;
        var formula = {$formula|raw};
        var peifangid = {$data['peifang']|default='0'};
        console.log(peifangid);
    var datas = []; //配方数据
    var xmd = xmSelect.render({
        el: '.peifang',
        tips: '请选择配方',
        initValue: [],
        name: 'peifang',
        filterable: true,
        radio: true,
        repeat: true,
        clickClose: true,
        cascader: {
            show: true,
            strict: true,
            indent: 250
        },
        prop: {
            name: 'title',
            value: 'id',
        },
        tree: {
            show: true,
            strict: false,
            showLine: false,
            simple: true,
        },
        model: {
            icon: 'hidden',
            label: {
                type: 'text'
            }
        },
        theme: {
            color: '#1890FF'
        },
        data() {
            return formula
        },
        on: function (onresult) {

        },
    })
    xmd.setValue([peifangid]);

  });
</script>